/*
 * SalaryEmployee.java
 *
 * This class is a derived class of class Employee and implements the interface
 * Tax. It is used to store the salary details and display the same.
 *
 * 
 */

package com.javacore.day6.maxsoft3;

/**
 * SalaryEmployee class is derived from Employee class and implements the
 * interface Tax.
 * @author 
 */
public class SalaryEmployee extends Employee implements Tax {
    
    /** Creates a new instance of SalaryEmploye. */
    public SalaryEmployee() {
    }
    
    /**
     * Creates a new instance of class SalaryEmployee and stores salary
     * in the instance variable and calls the base constructor.
     * @param name Parameter containing the name of the employee
     * @param salary Parameter containing the salary of the employee
     */
    public SalaryEmployee(String name, double salary) {
        super(name);
        this.salary = salary;
    }
    
    /**
     * Method to calculate the tax of salaried employees.
     * @return Returns the calculated tax
     */
    public double calculateTax() {
        return (this.salary * (TAX_PERCENT / 100));
    }
    
    /**
     * Method overriden to display the details of salaried employees.
     */
    void displayDetails() {
        System.out.printf("\nEmployee Name: %s\n", this.name);
        this.salary -= calculateTax();
        System.out.printf("Employee salary: %.2f\n", this.salary);
    }
    
    /**
     * Instance variable salary to store salary for salaried employees.
     */
    double salary;
}
